<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
	<title>菜单管理</title>
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
        
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>

    <script type="text/javascript">
    
    $(document).ready(function() {
    	$('#defaultForm')
        .bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                "t.text": {
                    validators: {
                        notEmpty: {
                            message: '菜单名称不能为空'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{4,10}$/,
                            message: '菜单名称的长度必须在4-10个汉字'
                        }
                    }
                },
                "t.href": {
                    validators: {
                        notEmpty: {
                            message: 'Url不能为空'
                        }
                    }
                },
                "t.parentId": {
                    validators: {
                        notEmpty: {
                            message: '主菜单不能为空'
                        }
                    }
                }
            }
        })
    });
    </script>
</head>
<body>
<div class="panel panel-primary">
  <div class="panel-heading">菜单管理</div>
  <div class="panel-body">
    
    <!-- 主菜单操作开始 -->
    <c:if test="${menus=='mainMenus' || params=='mainMenus'}">
	  <form id="defaultForm" class="form-horizontal" action="Mmenu/Mmenu_keep.action?params=0&page=${page}" method="post">
	  
		 <div class="form-group">
		    <label for="t.text" class="col-sm-offset-3 col-sm-2 control-label">菜单名称：</label>
		    <div class="col-sm-2">
		        <input class="form-control" type="text" name="t.text" id="text" placeholder="请输入菜单名称" value="${t.text}">
		    </div>
		  </div>

		 <div class="form-group">
		    <label for="t.menuNameen" class="col-sm-offset-3 col-sm-2 control-label">菜单英文名：</label>
		    <div class="col-sm-2">
		        <input class="form-control" type="text" name="t.menuNameen" id="menuNameen" placeholder="请输入菜单英文名" value="${t.menuNameen}">
		    </div>
		  </div>
          
		  <c:if test="${empty method}" >
			  <input type="hidden" name="t.status" value="0">
			  <input type="hidden" name="t.parentId" value="0">
		  </c:if>

	      <c:if test="${!empty method}" >
	          <input name="method" type="hidden" value="${method }">
			  <input type="hidden" name="t.id" value="${t.id}">
			  <input type="hidden" name="t.href"  value="${t.href}">
			  <input type="hidden" name="t.status" value="${t.status}">
			  <input type="hidden" name="t.parentId" value="${t.parentId}">
		  </c:if>
		 
		  <div class="form-group">
		    <div class="col-sm-offset-5 col-sm-7">
		      <button type="submit" class="btn btn-default">提交</button>
		      <button type="reset" class="btn btn-default">重置</button>
		    </div>
		  </div>
      </form>
   </c:if>   
   <!-- 主菜单操作结束 -->   
      
    
    <!-- 子菜单操作开始 -->  		  
  <c:if test="${menus=='subMenus' || params=='subMenus'}">
      <form id="defaultForm" class="form-horizontal" action="Mmenu/Mmenu_keep.action?params=1&page=${page}" method="post">
  
          <c:if test="${empty method}" >
			  <input type="hidden" name="t.status" value="0">
			  
			  <div class="form-group">
			    <label for="t.parentId" class="col-sm-offset-3 col-sm-2 control-label">选择主菜单：</label>
			    <div class="col-sm-2">
			        <select class="form-control" id="parentId" name="t.parentId" placeholder="请选择菜单名称" value="${t.parentId}">
			            <option value="" selected>请选择主菜单</option>
						<s:iterator value="#mains">
							<option value="<s:property value="id"/>">
					            <s:property value="text"/>
					        </option>
						</s:iterator>
			        </select>
			    </div>
		      </div>
		  </c:if>
		  
		  
		  <c:if test="${!empty method}" >
		      <input name="method" type="hidden" value="${method }">
			  <input name="t.id" type="hidden" value="${t.id}">
			  <input type="hidden" name="t.status" value="${t.status}">
			  <input type="hidden" name="t.parentId" value="${t.parentId}">
			  
			  <div class="form-group">
			    <label class="col-sm-offset-3 col-sm-2 control-label">主菜单名称：</label>
			    <div class="col-sm-2">
			        <label class="form-control">${m.text }</label>
			    </div>
			  </div>
		  </c:if>
		  
		 <div class="form-group">
		    <label for="t.text" class="col-sm-offset-3 col-sm-2 control-label">子菜单名称：</label>
		    <div class="col-sm-2">
		        <input class="form-control" type="text" name="t.text" id="text" placeholder="请输入菜单名称" value="${t.text}">
		    </div>
		  </div>

		 <div class="form-group">
		    <label for="t.menuNameen" class="col-sm-offset-3 col-sm-2 control-label">子菜单英文名：</label>
		    <div class="col-sm-2">
		        <input class="form-control" type="text" name="t.menuNameen" id="menuNameen" placeholder="请输入菜单英文名" value="${t.menuNameen}">
		    </div>
		  </div>
		  
		   <div class="form-group">
		    <label for="t.href" class="col-sm-offset-3 col-sm-2 control-label">子菜url：</label>
		    <div class="col-sm-2">
		        <input class="form-control" type="text" name="t.href" id="href" placeholder="请输入菜单url" value="${t.href}">
		    </div>
		  </div>
          
		  <div class="form-group">
		    <div class="col-sm-offset-5 col-sm-7">
		      <button type="submit" class="btn btn-default">提交</button>
		      <button type="reset" class="btn btn-default">重置</button>
		    </div>
		  </div>
      </form>
  </c:if>
    <!--子菜单操作开始 -->      
  </div>
  
</div>

</body>
</html>
